package com.token;

import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.crypto.MacProvider;

import java.security.Key;

public class KeyUtil {
	
	 public static void main(String[] args) {
		 KeyUtil.getKey();
     }
	 
	 public static String getKey(){
    	 Key key =MacProvider.generateKey(SignatureAlgorithm.HS512);
    	 byte[] keyBytes = key.getEncoded();
    	 String keyText = new sun.misc.BASE64Encoder().encodeBuffer(keyBytes);
    	 System.out.println("密钥："+keyText);
    	 return keyText;
    }

}
